const mysql = require('mysql2/promise');
const pool = require('../db');

class User {
    static async findOne(username) {
        const [rows] = await pool.query('SELECT * FROM users WHERE username = ?', [username]);
        return rows[0];
    }

    static async create(username, password, email) {
        const [result] = await pool.query('INSERT INTO users (username, password, email) VALUES (?, ?, ?)', [username, password, email]);
        return result.insertId;
    }
}

module.exports = User;